import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Text4 extends JFrame {

    private JLabel label = new JLabel("请输入:");
    private JTextField txtInput = new JTextField(15);
    private JButton btnOK = new JButton("确定");

    public Text4() {
        this.setLayout(new FlowLayout());
        this.add(label);
        this.add(txtInput);
        this.add(btnOK);
        this.setTitle("信息显示");
        this.setSize(400, 100);
        this.setVisible(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        btnOK.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                JOptionPane jP = new JOptionPane();
                jP.showMessageDialog(Text4.this, txtInput.getText());
            }
        });
    }

    public static void main(String[] args) {
        new Text4();
    }
}
